#ifndef __OPTICALFLOW_H
#define __OPTICALFLOW_H

#if defined (_WIN32)
	#include <windows.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>

#include "../GV/DataStruct/vec2.h"
#include "../GV/DataStruct/vec3.h"
#include <vector>
#include "convolution.h"
using namespace std;

class opticalFlow
{
public:
	opticalFlow (int window, int displacement, int wSize, int hSize);

	void calculate (unsigned char* oldScreen, unsigned char* newScreen);
	void calculateIxIyIt (unsigned char* oldScreen, unsigned char* newScreen);
	void draw (int xInit,int yInit,int xSize,int ySize);
	void calculateAB (int pixelX, int pixelY, int neighborSize);
	void inverseA ();
	void calculateUV (int pixelX, int pixelY);

	void calculateColor (vec3 *color, vec2 * vel);
	int m_window;
	int m_displacement;
	int m_wSize, m_hSize;
	vector<vec2> m_velocities;

	float* Ix,*Iy,*It;
	float matrixA[2][2];
	int vectorB[2];

	unsigned char *gaussOldImage, *gaussNewImage;

};

#endif
